<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8”>
<meta name="decorator" content="common_footer" />
<script type="text/javascript" src="${ctxWebStatic}/js/detail.js" ></script>
<script type="text/javascript" src="${ctxWebStatic}/js/swiper.jquery.min.js" ></script>
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script> 
<script>
	$(function(){
	    var swiper = new Swiper('.swiper-container', {
	        pagination: '.swiper-pagination',
	        paginationClickable: true,
	        autoplay:3000
	    });
	    $('.cancle').on('click',function(){
        	$('#showBox').hide();
		})
	    $(".goods_tab_title li").click(function(){
	    	$(".goods_tab_title li").removeClass("on");
	    	$(this).addClass("on");
	    	showIndex=$(this).index();
	    	$(".goods_tab_item").hide();
	    	$(".goods_tab_item").eq(showIndex).show();	
	    });
	    var html=$("#goods_introduce_html").val();
		var reg = new RegExp("a/sys/file/getFile","g");//g,表示全部替换
		html = html.replace(reg,'f/web/file/getFile');
		$(".goods_introduce_info").html(html);
	    /* if($.cookie('lastGoodCode1')!=null){
		    $('#lastGoodPrice1').text("¥"+$.cookie('lastGoodPrice1'));
		    $('#lastGoodCode1').attr('href',"${ctxWeb}/goodsDetail/list?goodsCode="+$.cookie('lastGoodCode1'));
		    $('#lastGoodImg1').attr('src',$.cookie('lastGoodImg1'));
		    $('#lastGoodName1').text($.cookie('lastGoodName1'));
	    }
	    if($.cookie('lastGoodCode2')!=null){
		    $('#lastGoodPrice2').text("¥"+$.cookie('lastGoodPrice2'));
		    $('#lastGoodCode2').attr('href',"${ctxWeb}/goodsDetail/list?goodsCode="+$.cookie('lastGoodCode2'));
		    $('#lastGoodImg2').attr('src',$.cookie('lastGoodImg2'));
		    $('#lastGoodName2').text($.cookie('lastGoodName2'));
	    }
	    if($.cookie('lastGoodCode3')!=null){
		    $('#lastGoodPrice3').text("¥"+$.cookie('lastGoodPrice3'));
		    $('#lastGoodCode3').attr('href',"${ctxWeb}/goodsDetail/list?goodsCode="+$.cookie('lastGoodCode3'));
		    $('#lastGoodImg3').attr('src',$.cookie('lastGoodImg3'));
		    $('#lastGoodName3').text($.cookie('lastGoodName3'));
	    	
	    }
	    if($.cookie('lastGoodCode4')!=null){
		    $('#lastGoodPrice4').text("¥"+$.cookie('lastGoodPrice4'));
		    $('#lastGoodCode4').attr('href',"${ctxWeb}/goodsDetail/list?goodsCode="+$.cookie('lastGoodCode4'));
		    $('#lastGoodImg4').attr('src',$.cookie('lastGoodImg4'));
		    $('#lastGoodName4').text($.cookie('lastGoodName4'));
	    }
	     */
	    
	   /*  $('#video').attr("src","${ctxWebStatic}/3gW5WJV6G02qdgIxlp0@@hd.mp4");
	    $("#video").attr("autoplay","autoplay");
	     */
	   
	   // document.write(returnCitySN["cip"]+','+returnCitySN["cname"])  
	    
	})
	
	
	$(document).ready(function(){
		var imgLength=	$('#showbox').find('img').length;
	  	var showproduct = {
			"boxid":"showbox",
			"sumid":"showsum",
			"boxw":428,//宽度,该版本中请把宽高填写成一样
			"boxh":428,//高度,该版本中请把宽高填写成一样
			"sumw":74,//列表每个宽度,该版本中请把宽高填写成一样
			"sumh":74,//列表每个高度,该版本中请把宽高填写成一样
			"sumi":14,//列表间隔
			"sums":imgLength,//列表显示个数
			"sumsel":"sel",
			"sumborder":0,//列表边框，没有边框填写0，边框在css中修改
			"lastid":"showlast",
			"nextid":"shownext"
			};//参数定义	  
	 $.ljsGlasses.pcGlasses(showproduct);//方法调用，务必在加载完后执行
	 
  });
	function addShoppingCart(store_code,goods_code){
		$.ajax({
			url : "${ctxWeb }/shoppingCart/addShoppingCart",
			data:{storeCode:store_code,goodsCode:goods_code},
			success : function(result) {
				if(result!=null){
					if(result.status=='0'){
						$('#showBoxTitle').text('商品不存在,请刷新页面');
						$('#showBox').show();
					}else if(result.status=='2'){
						$('#showBoxTitle').text('商品库存不足');
						$('#showBox').show();
					}else if(result.status=='2'){
						$('#showBoxTitle').text('商品已下架');
						$('#showBox').show();
					}else{
						$('#showBoxTitle').text('商品已成功加入购物车');
						$('#showBox').show();
					}
				}else{
					$('#showBoxTitle').text('系统异常');
					$('#showBox').show();
				}
			}
		});
		event.cancelBubble=true;
		return false;
	}
	function viewDetailGoods(goodsCode,storeCode){
		window.location.href = "${ctxWeb}/goodsDetail/list?goodsCode=" + goodsCode+"&storeCode="+storeCode+"&useIp="+returnCitySN["cip"];
	}
    </script>
</head>
<body >

	<!--手机端商品详情-->
	<div class="phone_detail_goods">
		<!--banner-->
		<div class="banner_rel ph_banner">
			<div class="swiper-container">
				<div class="swiper-wrapper">
					<c:if test="${not empty goodsDetail.imgList}">
						<c:forEach items="${goodsDetail.imgList}" var="imgList">
							<div class="swiper-slide">
								<a href="javascript:void(0)"> 
									<img src="${ctxWeb}/web/file/getFile?filePath=${imgList}" alt="" />
								</a>
							</div>
						</c:forEach>
					</c:if> 
				</div>
				<div class="swiper-pagination"></div>
			</div>
		</div>
		<div class="phone_msg_box">
			<figure class="item1">
				<h4>${goodsDetail.cnName}</h4>
				<p class="msg_price">
					<b>配件编号：</b><span>${goodsDetail.partCode}</span>
				</p>
				<c:choose>
					<c:when test="${goodsDetail.status==1&&goodsDetail.storeStatus=='1'}">
						<p>
							<b>售价：</b><span class="phone_price">¥${goodsDetail.price}</span>
						</p>
						<p class="phone_member">
							<b>会员价：</b>
							<span>
								<c:choose>
									<c:when test="${not empty use.userType&&use.userType==2}">
										¥${goodsDetail.vipPrice}
									</c:when>
									<c:otherwise>
										会员可见
									</c:otherwise>
								</c:choose>
							</span>
						</p>
					</c:when>
					<c:when test="${goodsDetail.storeStatus==2}">
					<p>
						<b></b><span class="phone_price">该门店已失效</span>
					</p>
					
					</c:when>
					<c:when test="${goodsDetail.status==0}">
						<b></b><span class="phone_price">该商品已下架</span>
					</c:when>
					<c:when test="${goodsDetail.status==2}">
						<b></b><span class="phone_price">该商品已下架</span>
					</c:when>
				</c:choose>
				
			</figure>
			<figure class="item2">
				<p>
					<b>制造商：</b><span>${goodsDetail.venderName}</span>
				</p>
				<p>
					<b>门店 ：</b><span>${goodsDetail.storeName}</span>
				</p>
				<p>
					<b>区域 ：</b><span>${goodsDetail.areaName}</span>
				</p>
			</figure>
		</div>
		<!--banner结束-->
	</div>
	<!--手机端商品详情结束-->
	<!--pc商品详情-->
	<div class="goods_detail_box">
		<div class="container">
			<div class="row">
				<div class="detail_box  clearfix">
					<!--左边-->
					<div class="detail_left">
						<div id="showbox">
							<c:if test="${not empty goodsDetail.imgList}">
								<c:forEach items="${goodsDetail.imgList}" var="imgList">
									 <img src="${ctxWeb}/web/file/getFile?filePath=${imgList}" width="418" height="418" />
								</c:forEach>
							</c:if> 
						</div>
						<!--展示图片盒子-->
						<div id="showsum" style='margin-left: -39px;'></div>
						<!--展示图片里边-->
					</div>
					<!--左边结束-->
					<!--右边开始-->
					<div class="detail_right">
						<div class="msg_info">
							<p class="msg_title noWrapEllipsis">${goodsDetail.cnName}</p>
							<p class="msg_seller">
								<b>${fns:getDictLabel(goodsDetail.storeType, 'store_type', '')}</b><span>制造商：${goodsDetail.venderName}</span>
							</p>
							<p class="msg_price">
								<b>配件编号：</b><span>${goodsDetail.partCode}</span>
							</p>
						</div>
						
						<c:choose>
							<c:when test="${goodsDetail.status==1&&goodsDetail.storeStatus==1}">
								<div class="sum_over">
									<p class="sum_Member">
										<b>会员价</b> 
										<span class="color_red">
										<c:choose>
											<c:when test="${not empty user.userType&&user.userType==2}">
													¥ ${goodsDetail.vipPrice}
												</c:when>
												<c:otherwise>
													会员可见
												</c:otherwise>
											</c:choose>
										
										</span>
									</p>
									<p class="sum_oldprice">
										<b>标价</b> <span class="gry">¥ ${goodsDetail.price}</span>
									</p>
									<p class="sum_active">
										<!-- <b>活动</b> <span class="color_red">升级全会员，全场满1000免邮费</span> -->
									</p>
								</div>
							</c:when>
							<c:when test="${goodsDetail.storeStatus==2}">
								<div class="sum_over">
									<p class="sum_Member">
										<span class="color_red">
											该门店已失效
										</span>
									</p>
								</div>
							</c:when>
							<c:when test="${goodsDetail.status==0}">
								<div class="sum_over">
									<p class="sum_Member">
										<span class="color_red">
											该商品已下架
										</span>
									</p>
								</div>
							</c:when>
							<c:when test="${goodsDetail.status==2}">
								<div class="sum_over">
									<p class="sum_Member">
										<span class="color_red">
											该商品已下架
										</span>
									</p>
								</div>
							</c:when>
						</c:choose>
						
						<c:choose>
						<c:when test="${goodsDetail.status==1}">
							<div class="msg_address">
								<p>
									<b>门店 ：</b> <span>${goodsDetail.storeName}</span>
								</p>
								<p>
									<b>区域 ：</b> <span>${goodsDetail.areaName}</span>
								</p>
							</div>
						</c:when>
						</c:choose>
						<div class="jion_btn">
							<c:choose>
								<c:when test="${goodsDetail.status==1&&goodsDetail.storeStatus==1}">
									<a href="${ctxWeb }/shoppingCart/buyNow?storeCode=${goodsDetail.storeCode}&goodsCode=${goodsDetail.goodsCode }" class="go_buy">立即购买</a> 
									<a onclick="addShoppingCart('${goodsDetail.storeCode}','${goodsDetail.goodsCode }')" href="javascript:;" class="enter_shopping">加入购物车</a>
								</c:when>
								<c:otherwise>
									<!-- <a class="go_buy">立即购买</a> 
									<a class="enter_shopping">加入购物车</a> -->
								</c:otherwise>
							</c:choose>
							
						</div>
					</div>
					<!--右边结束-->
				</div>
			</div>
		</div>
	</div>
	<!--pc商品详情结束-->
	<!--商品详情列表-->
	<div class="goods_list_box">
		<div class="container">
			<div class="row">
				<div class="col-sm-9 pad0">
					<div class="goods_tab_box">
						<div class="goods_tab_title">
							<ul class="clearfix">
								<li class="on"><a href="javascript:void(0)">商品详情</a></li>
								<li><a href="javascript:void(0)">适用车型</a></li>
								<li><a href="javascript:void(0)">售后服务</a></li>
							</ul>
						</div>
						<div class="goods_tab_list">
							<div class="goods_tab_item">
								<!--viedo-->
								<c:if test="${goodsDetail.videoUrl!=null&&goodsDetail.videoUrl!=''}">
									<video width="100%" controls="controls" id="video" autoplay="autoplay">
							  			<source src="${ctxWeb}/web/file/getFile?filePath=/jpBusinessVideo/${goodsDetail.videoUrl}" type="video/mp4" preload="none">
									</video>
								</c:if>
								<!--video结束-->
								<input type="hidden" id="goods_introduce_html" value="${goodsDetail.goodsIntroduce}"/>
								<div class="goods_introduce_info">
											
								</div>
								<p>

									<c:forEach items="${goodsDetail.detailImgList}" var="detailImg">
										<img src="${ctxWeb}/web/file/getFile?filePath=${detailImg}" alt="" />
									</c:forEach>

									<%-- <img src="${ctxWeb}/web/file/getFile?filePath=${goodsDetail.detailImg}" alt="" /> --%>
								</p>
							</div>
							<div class="goods_tab_item" style="display: none;">
									<c:forEach items="${goodsDetail.carList}" var="carList">
										<p>${carList}</p>
									</c:forEach>
							</div>
							<div class="goods_tab_item" style="display: none;">
								<p>
									<c:forEach items="${goodsDetail.serviceImgList}" var="serviceImg">
										<img src="${ctxWeb}/web/file/getFile?filePath=${serviceImg}" alt="" />
									</c:forEach>
									<%-- <img src="${ctxWeb}/web/file/getFile?filePath=${goodsDetail.serviceImg}" alt="" /> --%>
								</p>
							</div>
						</div>
					</div>
				</div>
				<div class="col-sm-3 pad20">
					<c:if test="${not empty historyList}">
						<div class="goods_history_box" id="historyPart">
							<h3 class="title">历史浏览</h3>
							<ul class="goods_history_list">
									<c:forEach items="${historyList}" var="goods">
										<li>
											<a onclick="viewDetailGoods('${goods.goodsCode}','${goods.storeCode}')">
												<c:if test="${not empty goods.imgList}">
													<img src="${ctxWeb}/web/file/getFile?filePath=${goods.imgList[0]}" alt="">
												</c:if>
												<c:if test="goods.storeStock==0">
													<p class="pos_goods">暂时无货</p>
												</c:if>
												<p class="look_price">￥${goods.price}</p>
												<p class="goods_name">${goods.cnName}</p>
											</a>
										</li>
									</c:forEach>
							</ul>
						</div>
					</c:if>
				</div>
			</div>
		</div>
	</div>
	<!--商品详情列表切换-->
	<!--手机端购物车-->
	<div class="fix_bootom_box">
		<c:choose>
			<c:when test="${goodsDetail.status==1&&goodsDetail.storeStatus==1}">
	
				<figure class="fix_buy">
					<a href="${ctxWeb }/shoppingCart/buyNow?storeCode=${goodsDetail.storeCode}&goodsCode=${goodsDetail.goodsCode }">立即购买</a>
				</figure>
				<figure class="fix_shop">
					<a onclick="addShoppingCart('${goodsDetail.storeCode}','${goodsDetail.goodsCode }')" href="javascript:;">加入购物车</a>
				</figure>
			</c:when>
		</c:choose>
	</div>
	<!--手机端购物车结束-->
	<div class="jd_tk jd_tk_del_box" id="showBox" style="display: none;">
	    <div class="delet_box">
	        <div class="jd_win_tit" id="showBoxTitle"></div>
	        <div class="jd_btn clearfix">
	            <a href="javascript:void(0)" class="cancle">返回</a>
	            <a href="${ctxWeb }/shoppingCart" class="submit" >查看购物车</a>
	        </div>
	    </div>
	</div>
</body>



</html>
